package vistas;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JInternalFrame;
import javax.swing.JList;
import java.awt.Rectangle;
import javax.swing.JButton;

import controlador.Controlador;

import java.awt.Dimension;
import java.rmi.RemoteException;
import javax.swing.JTextField;
import javax.swing.JLabel;

import modelo.InterfazRemota;

public class AbrirMesa extends JInternalFrame {

	private InterfazRemota neg;
	private Controlador controlador;
	private JPanel jContentPane = null;
	private JButton AbrirMesa = null;
	private JButton CerrarMesa = null;
	private JButton Salir = null;
	private JTextField nroMesa = null;
	private JLabel numeroMesa = null;

	/**
	 * This is the xxx default constructor
	 */
	public AbrirMesa(InterfazRemota negocio) {
		super();
		initialize();
		this.neg = negocio;
		this.setVisible(true);
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(372, 226);
		this.setTitle("Abrir o Cerrar Mesa");
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			numeroMesa = new JLabel();
			numeroMesa.setBounds(new Rectangle(19, 52, 158, 19));
			numeroMesa.setText("Ingrese numero de mesa:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getAbrirMesa(), null);
			jContentPane.add(getCerrarMesa(), null);
			jContentPane.add(getSalir(), null);
			jContentPane.add(getNroMesa(), null);
			jContentPane.add(numeroMesa, null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes AbrirMesa	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getAbrirMesa() {
		if (AbrirMesa == null) {
			AbrirMesa = new JButton();
			AbrirMesa.setBounds(new Rectangle(195, 25, 140, 33));
			AbrirMesa.setText("Abrir la mesa");		
			AbrirMesa.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String num = getNroMesa().toString();
					int n= Integer.parseInt(num);
					try {
						controlador.abrirMesa(n);
					} catch (RemoteException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				}
			});
		}
		return AbrirMesa;
	}

	/**
	 * This method initializes CerrarMesa	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCerrarMesa() {
		if (CerrarMesa == null) {
			CerrarMesa = new JButton();
			CerrarMesa.setBounds(new Rectangle(195, 85, 140, 33));
			CerrarMesa.setText("Cerrar la mesa");
			CerrarMesa.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String num = getNroMesa().toString();
					int n= Integer.parseInt(num);
					try {
						controlador.cerrarMesa(n);
					} catch (RemoteException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				}
			});
		}
		return CerrarMesa;
	}

	/**
	 * This method initializes Salir	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getSalir() {
		if (Salir == null) {
			Salir = new JButton();
			Salir.setBounds(new Rectangle(136, 146, 89, 30));
			Salir.setText("Salir");
		}
		return Salir;
	}

	/**
	 * This method initializes nroMesa	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNroMesa() {
		if (nroMesa == null) {
			nroMesa = new JTextField();
			nroMesa.setBounds(new Rectangle(69, 80, 47, 33));
		}
		return nroMesa;
	}
	
	public void setControlador(Controlador controlador) {
		this.controlador = controlador;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
